<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        // set去重
       let arr1=[1,2,3,4,5];
       let arr2=[4,5,8,6,2,3];
       var b=new Set(arr2);//将arr2赋值给 b
       console.log(b);
       let arr3=[...new Set(arr1.filter(x=>b.has(x)))];
       console.log(arr3);
       let result =arr1.filter(item => arr2.includes(item));
       console.log(result);
    </script>
</body>

</html>